package com.diudiutechnology.www.yadiudiu.yadiudiu.car.MyAdapter;

import android.content.Context;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.diudiutechnology.www.yadiudiu.yadiudiu.model.BuyACarFragmentModel;
import com.diudiutechnology.www.yadiudiu.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/8/21.
 * 店铺详情 ——精选服务
 */

public class ShopSelectServiceAdapter  extends BaseAdapter {

    private Context mContext;
    List<BuyACarFragmentModel> model= new ArrayList<>();
    public ShopSelectServiceAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public int getCount() {
        return model.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    public void addItem( List<BuyACarFragmentModel> model){
        this.model=model;
        notifyDataSetChanged();
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = LayoutInflater.from(mContext).inflate(
                    R.layout.item_select_service, null);
            holder.item_image = (ImageView) convertView
                    .findViewById(R.id.item_image);
            holder.standard_car_wash_text = (TextView) convertView
                    .findViewById(R.id.standard_car_wash_text);

            holder.standard_car_wash_present = (TextView) convertView
                    .findViewById(R.id.standard_car_wash_present);
            holder.standard_car_wash_content = (TextView) convertView
                    .findViewById(R.id.standard_car_wash_content);
            holder.standard_car_wash_original = (TextView) convertView
                    .findViewById(R.id.standard_car_wash_original);
            holder.line = (TextView) convertView
                    .findViewById(R.id.line);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
if (position==0){
    holder.item_image.setImageResource(R.mipmap.selected);
}else {
    holder.item_image.setImageResource(R.mipmap.uncheck);
}
if (position==model.size()-1){
    holder.line.setVisibility(View.INVISIBLE);
}else {
    holder.line.setVisibility(View.VISIBLE);
}
        BuyACarFragmentModel bModel = model.get(position);
        holder.standard_car_wash_text.setText(bModel.getName());
        holder.standard_car_wash_present.setText(bModel.getMoney1());
        holder.standard_car_wash_original.setText(bModel.getMoney2());
        holder.standard_car_wash_original.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG);
        holder.standard_car_wash_content.setText(bModel.getLet());
        return convertView;
    }

    class ViewHolder {
        ImageView item_image;
        TextView standard_car_wash_text;
        TextView standard_car_wash_present;
        TextView standard_car_wash_content;
        TextView standard_car_wash_original;
        TextView line;
    }
}


